<?php
session_start();
ob_start('ob_gzhandler');
include_once('config.php');

if(@$_GET['danhmuc']){
	$dm = $_GET['danhmuc'];
	$dm = explode('/',$dm);
	$danhmuc = $dm[0];
	if($dm[1]=='') $page = 1; else $page = $dm[1];
	$menu_one = $tc->menu_one($danhmuc);
	$row_menu_one = mysql_fetch_array($menu_one);
	$idMenu = $row_menu_one['id'];
	$type = $row_menu_one['type_id'];
	$slogan = "<h6>{$row_config['slogan']}</h6>";
	if(!@$_GET['detail']){
		$navigator = '<div class="title"><h1>'.$row_menu_one['title'].'</h1></div>';
		($row_menu_one['url_hinh']=='') ? $image='http://'.$domain.'/'.url_default_image : $image='http://'.$domain.'/'.url_danhmuc_image.$row_menu_one['url_hinh'];
		$url = 'http://'.$domain.'/'.$row_menu_one['url'];
		$seo = $tc->seo($domain,$row_menu_one['title'],$row_menu_one['metaDescription'],$row_menu_one['metaKeyword'],$image,$url);
		switch($type){
			case 2 : include_once('blocks/list_articles.php'); break;
			case 3 : include_once('blocks/list_product.php'); break;
			case 7 : include_once('blocks/contact.php'); break;
			default: $view_post = '<font color="#FF0000"><b>Could not be found</b></font>';
		}
	}else{
		$dt = $_GET['detail'];
		$detail = $tc->detail($dt);
		$row_detail = mysql_fetch_array($detail);
		($row_detail['url_hinh']!='') ? $image='http://'.$domain.'/'.url_detail_thumb_image.$row_detail['url_hinh'] : $image='http://'.$domain.'/'.url_default_image;
		$url = 'http://'.$domain.'/'.$row_menu_one['url'].$row_detail['name_rewrite'].'.html';
		$seo = $tc->seo($domain,$row_detail['name'],$row_detail['description'],$row_detail['metaKeyword'],$image,$url);
		include_once('blocks/articles.php');
	}
}else{
	$menu_one = $tc->menu_one('trang-chu');
	$row_menu_one = mysql_fetch_array($menu_one);
	$url = 'http://'.$domain;
	($row_menu_one['url_hinh']=='') ? $image='http://'.$domain.'/'.url_default_image : $image='http://'.$domain.'/'.url_danhmuc_image.$row_menu_one['url_hinh'];
	$seo = $tc->seo($domain,$row_menu_one['title'],$row_menu_one['metaDescription'],$row_menu_one['metaKeyword'],$image,$url);
	$slogan = "<h1>{$row_config['slogan']}</h1>";
	include_once('blocks/home.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $seo; ?>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="library/jquery.js"></script>
<script type="text/javascript" src="website.js"></script>
<link href="assets/wt-rotator.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="assets/jquery.wt-rotator.min.js"></script>
<script type="text/javascript" src="assets/preview.js"></script>
</head>

<body>

<div id="wrapper">
	<div id="header"><a href="/" title="Rượu sim Phú Quốc"><img src="images/logo.jpg" alt="rượu sim Phú Quốc" /></a><?php echo $slogan;?><div id="search"><div id="hotline">Hotline: <span>098 388 6868</span></div><div id="frmsearch"><input type="text" name="txtSearch" value="Tìm trên google" id="txtSearch" onclick="if(value=='Tìm trên google') value=''" /><input type="button" name="btnSearch" value="&nbsp;" onClick="SearchGoogle();" id="btnSearch" /><script type="text/javascript">function SearchGoogle(){	var key = document.getElementById("txtSearch").value; var site = document.domain; var qs = key + "+site:" + site; var url = "http://www.google.com.vn/#sclient=psy-ab&hl=vi&site=&source=hp&q=" + qs + "&pbx=1&oq=" + qs + "&aq=f&aqi=&aql=1&gs_sm=e"; window.open(url, '_blank'); return false;}</script></div></div></div><!--header-->
	<?php
    include_once('blocks/menu.php');
	include_once('blocks/slider.php');
	?>
	<div id="content"><?php echo $view_post;?> </div>
</div>

<?php
$view_foo = '<div id="footer"><div style="width:920px; margin:auto"><div id="left_foo">'.$row_config['footer'].'</div><div id="right_foo">';
$menu_foo = $tc->menu(0,2);
$i = 0;
while($row = mysql_fetch_array($menu_foo)){
	$i++;
	if($i!=1) $view_foo .= '|<a href="'.$row['url'].'" title="'.$row['title'].'">'.$row['name'].'</a>';
	else $view_foo .= '<a href="/" title="Rượu Sim Phú Quốc">Trang chủ</a>';
}
echo $view_foo.'</div></div></div>';

include_once('blocks/social.php');
?>
</body>
</html>
<?php mysql_close();?>